<!-- 隐患库新增编辑 -->
<template>
  <div>
    <el-dialog v-bind="dialogProps" :before-close="handleClose" :close-on-click-modal="false"
               :destroy-on-close="true" v-dialogDrag>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm"
               size="small">
        <el-row :gutter="16" justify="start">
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="单位名称:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择单位名称" clearable style="width:100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="创建人:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入创建人" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="隐患名称:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入隐患名称" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="隐患位置:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入隐患位置" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="详细地点:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入详细地点" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="详细描述:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入详细描述" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="发现班组:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择发现班组" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="发现人:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入发现人" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="发现日期:" prop="jhkssj">
              <el-date-picker v-model="ruleForm.jhkssj" type="datetime" style="width:100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="隐患类型:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择隐患类型" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="站线类型:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择站线类型" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="站线名称:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入站线名称" clearable></el-input>

            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="电压等级:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择电压等级" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="设备名称:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入设备名称" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="设备型号:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入设备型号" clearable disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="生产厂家:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入生产厂家" clearable disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="问题分类:" prop="xsmc">
              <el-input v-model="ruleForm.xsmc" placeholder="请输入问题分类" clearable disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="处理状态:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择处理状态" clearable style="width: 100%" disabled>
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="16" justify="start">
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="线路重要等级:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择线路重要等级" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="线路常态化等级:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择线路常态化等级" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="隐患分类:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择隐患分类" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="隐患性质:" prop="xsmc">
              <el-select v-model="ruleForm.xsmc" placeholder="请选择隐患性质" clearable style="width: 100%">
                <el-option v-for="item in zxoptions" :key="item.value" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="消缺前照片上传:" prop="xsmc">
              <el-button>照片上传</el-button>
            </el-form-item>
          </el-col>

        </el-row>

      </el-form>

      <span slot="footer" class="dialog-footer" v-if="footerVisible">
                <el-button @click="handleCancel()" :size="size" icon="fa fa-minus-square-o">取消</el-button>
                <el-button type="primary" @click="handleSubmit()" :size="size"
                           icon="fa fa-save (alias)">确定</el-button>
            </span>
    </el-dialog>
  </div>
</template>
<script>
import {defectFrom} from "../model/defectFrom";

export default {
  components: {},
  data() {
    return {
      dialogProps: {
        visible: false,
        title: "隐患库新增",
        width: "70%",
        top: "5px",
      },
      footerVisible: true,
      size: "medium",
      ruleForm: defectFrom.FormData,
      rules: defectFrom.rules,
      disabledForm: true,
      zxoptions: [],
      xsnrShow: true,
      list: {
        data: []
      },
      row: {}
    };
  },
  methods: {
    showDialog(isEdit, row, isDisabled) {
      console.log(isEdit, row, isDisabled, 1111);
      if (isEdit) {
        this.initData();
      }
      this.ruleForm.jhkssj = moment().add('1', 'days').format('YYYY-MM-DD 8:00:00')
      this.ruleForm.jhjssj = moment().add('1', 'days').format('YYYY-MM-DD 20:00:00')
      this.dialogProps.visible = true;
    },
    //任务库弹窗
    TaskModel() {
      this.$refs.taskLibrary.showDialog()


    },
    //选择对象弹窗
    alternativeModel() {
      this.$refs.alternative.showDialog()

    },
    //列表选择杆塔弹窗
    towerClick() {
      this.$refs.tower.showDialog()
    },
    //编辑渲染
    initData() {
    },
    //确定
    handleSubmit() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.handleCancel()
          this.dialogProps.visible = false;
        } else {
          return false;
        }
      });

    },
    //取消
    handleCancel() {
      this.$refs.ruleForm.resetFields()
      // for (const k in this.form.data) {
      //   this.form.data[k] = ''
      // }
      this.list = {
        data: [],
      }
      this.row = {}
      this.dialogProps.visible = false;
    },
    //确定关闭
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.handleCancel()
          this.dialogProps.visible = false;
        })
        .catch((_) => {
        });
    },
  },
};

</script>
<style>
.el-dialog__footer {
  width: 100%;
  border-top: 1px solid #e8e8e8;
}
</style>
